package com.ruoyi.common.enums;


import com.ruoyi.common.exception.ServiceException;
import lombok.Getter;

import java.util.Arrays;


@Getter
public enum BaseIsDeletedEnum implements BaseInteger{
    EXISTS(0, "存在"),
    DELETED(1, "已删除");

    private final Integer code;
    private final String desc;
    BaseIsDeletedEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 可选：每个枚举类可以定义自己的fromCode方法
    public static BaseIsDeletedEnum fromCode(Integer code) {
        return BaseInteger.fromCode(BaseIsDeletedEnum.class, code);
    }

    @Override
    public BaseIsDeletedEnum valOf(Integer code) {
        return Arrays.stream(BaseIsDeletedEnum.values()).filter(item -> item.code.equals(code)).findFirst().orElseThrow(() -> new ServiceException("枚举转换异常"));
    }
}
